<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="org.swimv2.entities.*" %>
<%@ page import="org.swimv2.interfaces.*"%>
<%@ page import="javax.naming.*" %>
<%@ page import="org.swimv2.utils.ContextUtil" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<% 
User curr_u = (User) request.getSession().getAttribute("user");
int j_id = Integer.parseInt(request.getParameter("job_id"));


Context ctx = ContextUtil.getInitialContext();
JobsManagerRemote mgr_j = (JobsManagerRemote) ctx.lookup("JobsManagerJNDI");
Job j = mgr_j.getJob(j_id);
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
@import url(/WEBswim2/css/main.css);
</style>
<title>Leave Feedback</title>
</head>
<body>


<p class="homenav"><a href="/WEBswim2/home.jsp"><span>Home</span></a></p>
<% if (curr_u != null) { %>
<ul class="ul_nav">
    <li><a href="/WEBswim2/user/profile.jsp">Il Mio Profilo</a> <em>[<% out.print(curr_u.getFirstName() +" "+ curr_u.getLastName()); %>]</em></li>
    <% if (curr_u.getIsAdmin()) { %><li><a href="/WEBswim2/admin/profile.jsp">Pannello di controllo Amministratore</a></li><% } %>
    <li><a href="/WEBswim2/Logout">Logout</a></li>
</ul>
<% } %>

<h1>Lascia un feedback:</h1>
<%
    String err = (String) request.getAttribute("error_message");
    if (err != null) {
        out.println("<p class=\"error_message\">" + err + "</p>");
    } else {
%>

<%
if (j != null && curr_u != null && curr_u.getId() == j.getClient().getId()) {
%>
<form action="/WEBswim2/LeaveFeedback" method="post">
  <fieldset>
    <label for="star">Valutazione lavoro:</label><br/>
    <select name="stars">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5" selected="selected">5</option>
    </select><br/>
    <label for="desc">Feedback:</label><br/>
    <input type="text" name="desc"/><br/>
    <input type="hidden" name="job_id" value="<% out.print(Integer.toString(j_id)); %>" />
    <input type="submit" name="submit" value="Invia"/>
  </fieldset>
</form>
<% } %>

<% } %>

</body>
</html>